@echo off
chcp 65001 >nul
cls
color 0E

echo.
echo ════════════════════════════════════════════
echo   诊断模拟位置问题
echo ════════════════════════════════════════════
echo.

echo [1/5] 检查模拟位置权限...
echo.
adb shell appops get com.example.munidingwei MOCK_LOCATION
echo.
set /p dummy=按回车继续...

echo.
echo [2/5] 检查应用是否运行...
echo.
adb shell ps | findstr munidingwei
echo.
set /p dummy=按回车继续...

echo.
echo [3/5] 检查前台服务状态...
echo.
adb shell dumpsys activity services com.example.munidingwei | findstr LocationForegroundService
echo.
set /p dummy=按回车继续...

echo.
echo [4/5] 检查系统位置状态...
echo.
adb shell dumpsys location | findstr "mock\|test"
echo.
set /p dummy=按回车继续...

echo.
echo [5/5] 查看最近的日志...
echo.
echo === LocationService 日志 ===
adb logcat -d -s LocationService:D | tail -n 30
echo.
echo === LocationForegroundService 日志 ===
adb logcat -d -s LocationForegroundService:D | tail -n 30
echo.
echo === MockLocationProvider 日志 ===
adb logcat -d -s MockLocationProvider:D | tail -n 30
echo.

pause

echo.
echo ════════════════════════════════════════════
echo  实时监控
echo ════════════════════════════════════════════
echo.
echo 开始实时监控日志，请在手机上操作...
echo.
echo 📱 请在手机上：
echo    1. 点击或拖动地图选择位置
echo    2. 设置为模拟位置
echo.
echo 按 Ctrl+C 停止监控
echo.

adb logcat -c
adb logcat LocationService:D LocationForegroundService:D MockLocationProvider:D *:S

pause

